﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Microsoft.Xna.Framework;

namespace Client {

    class LivingEntity : Entity {

        private int m_MaxHealth;

        private int m_CurrentHealth;

        public LivingEntity(int maxHealth) {
            this.m_MaxHealth = maxHealth;
            this.m_CurrentHealth = maxHealth;
        }

        public void setMaxHealth(int maxHealth) {
            this.m_MaxHealth = maxHealth;
        }

        public void setHealth(int health) {
            m_CurrentHealth = (health < 0) ? 0 : (health > m_MaxHealth) ? m_MaxHealth : health;
        }

        public int damage(int amount) {
            m_CurrentHealth -= amount;
            if(m_CurrentHealth < 0) {
                amount += m_CurrentHealth;
                m_CurrentHealth = 0;
            }

            return amount;
        }

        public int heal(int amount) {
            m_CurrentHealth += amount;
            if(m_CurrentHealth > m_MaxHealth) {
                amount -= (m_CurrentHealth - m_MaxHealth);
                m_CurrentHealth = m_MaxHealth;
            }
            return amount;
        }

        public bool isDead() {
            return (m_CurrentHealth == 0);
        }

    }

}
